/*
tool.h
offer some small tools function extern
designed by lunanting 

---------------------------
2021-10-08 16:57:14
create file
*/
#ifndef __TOOL_H
#define __TOOL_H

#include <stddef.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
#include <k_api.h>
#include <aos/errno.h>
#include <aos/kernel.h>

/* binary sem struct, add by maoxinfeng */
typedef struct{
	bool sem;
	aos_mutex_t mutex;
} binary_sem_t;


/*******************************extern *****************************/
extern uint64_t get_diff_ms(uint64_t start_time);


/* binary sem api, add by maoxinfeng */
int binary_sem_new(binary_sem_t *bin_sem);
void binary_sem_free(binary_sem_t *bin_sem);
void binary_sem_signal(binary_sem_t *bin_sem);
bool binary_sem_wait(binary_sem_t *bin_sem, unsigned int timeout);
int binary_sem_is_valid(binary_sem_t *bin_sem);

#endif
//end of the file
